﻿myApp.factory('MoviesService', function () {
    //Array of movies
    var movies = [];

    // Array of BLog Articles
    var posts = [];
    // Constructor
    // title - title of article
    // date - date published
    // author - author
    // body - full article
    function Article(title, date, author, body) {
        this.title = title,
        this.date = date,
        this.author = author,
        this.body = body
    }
    //
    var a1 = new Article("js 101", "1/2/2015", "Rick James", "Lorum ipsum dolor etal");
    var a2 = new Article("angular 101", "2/2/2015", "Bill Gates", "lhjlijljlij Lorum ipsum dolor etal");
    var a3 = new Article("c# is awesome", "4/2/2015", "Tony N", "Lorum ipsum dolor etal");
    posts.push(a1, a2, a3);





    /*
    Constructor MOVIE - DATA model/structure
    title   - name of the movie
    rate    - the movie classification (pg, pg-13, r)
    date    - release date 
    summary - description of the movie
    */
    function Movie(title, rate, date, summary) {
        this.title = title,
        this.rate = rate,
        this.date = date,
        this.summary = summary
    }
    // create a few 'movie' objects
    var mov1 = new Movie("Bambi", "pg", "1980", "Bunnies and flowers");
    var mov2 = new Movie("Avengers pt5", "r", "2015", "StanLee stars as the hero");
    var mov3 = new Movie("American Sniper", "g", "2014", "Sharpshooter saves 'merica");
    // Add movies to the Array
    movies.push(mov1, mov2, mov3);

    // Expose varialbes & methods to Controller
    return {
        movies: movies,
        posts: posts
    }

});